class Admin::OptionValuesController < AdminController

  def create
    @option_value = OptionValue.new option_value_params
    if @option_value.save
      redirect_to admin_shop_category_option_types_path(@option_value.option_type.shop_category), notice: "保存成功！"
    else
      redirect_to admin_shop_category_option_types_path(@option_value.option_type.shop_category), notice: "保存失败！"
    end
  end
  
  def destroy
    @option_value = OptionValue.find params[:id]
    if @option_value.destroy
      redirect_to admin_shop_category_option_types_path(@option_value.option_type.shop_category), notice: "删除成功."
    else
      redirect_to admin_shop_category_option_types_path(@option_value.option_type.shop_category), notice: "删除失败."
    end
  end

  private

  def option_value_params
    params.require(:option_value).permit(:name, :presentation, :option_type_id)
  end
end
